home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_BackFillRoutine.c < prev    next >
C/C++ Source or Header  |  1996-10-11  |  5KB  |  205 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14.     // Layer backfill hook support
  15.  
  16. struct LayerMsg
  17. {
  18.     struct Layer        *Layer;
  19.     struct Rectangle     Bounds;
  20. };
  21.  
  22.  
  23. VOID SAVE_DS ASM
  24. LTP_BackfillRoutine(REG(a0) struct Hook *Hook,REG(a1) struct LayerMsg *Bounds,REG(a2) struct RastPort *RPort)
  25. {
  26.     LayoutHandle *Handle = (LayoutHandle *)Hook->h_Data;
  27.  
  28.         // Make a copy of the rastport
  29.  
  30.     CopyMem(RPort,&Handle->BackfillRastPort,sizeof(struct RastPort));
  31.  
  32.         // Zap the layer pointer, we have to do this
  33.  
  34.     Handle->BackfillRastPort.Layer = NULL;
  35.  
  36.         // Now for the colours and drawing mode
  37.  
  38.     LTP_SetPens(&Handle->BackfillRastPort,Handle->BackgroundPen,0,JAM2);
  39.  
  40.         // Clear the area
  41.  
  42.     RectFill(&Handle->BackfillRastPort,Bounds->Bounds.MinX,Bounds->Bounds.MinY,Bounds->Bounds.MaxX,Bounds->Bounds.MaxY);
  43. }
  44.  
  45. /*
  46. VOID SAVE_DS ASM
  47. LTP_BackfillRoutine(REG(a0) struct Hook *Hook,REG(a1) struct LayerMsg *Bounds,REG(a2) struct RastPort *RPort)
  48. {
  49.     STATIC UWORD __chip EscherData[216] =
  50.     {
  51.         0xFFF0,0xFFE7,0xF703,0xFF00,0xFFFF,0xFFF9,0xF801,0xFF00,
  52.         0xFFFF,0xFFFE,0xF000,0xFF00,0xFFFF,0xFCFF,0x6000,0x7F00,
  53.         0xFFFF,0xFF3F,0x8020,0x7F00,0xFFFF,0xFFCF,0xC000,0x9F00,
  54.         0xFFFF,0xFFF7,0x8001,0x0700,0xFFFF,0xFFFB,0x8001,0x0100,
  55.         0xFFFF,0xFFFD,0x0001,0x0000,0xFFFF,0xFFFE,0x007F,0xFF00,
  56.         0xFFFF,0xFFFF,0x00FF,0xFF00,0xFFFF,0xFFFF,0x00FF,0xFF00,
  57.         0xFE7F,0xFFFF,0x00FF,0xFF00,0x7F9F,0xFFFF,0x807F,0xFE00,
  58.         0x9FEF,0xFFFF,0x807F,0xFF00,0xE7F7,0xFFFF,0x803F,0x9F00,
  59.         0xFBF8,0x07FF,0xA00F,0xE700,0xFDE0,0x007F,0xB007,0xF900,
  60.         0xFEC0,0x009F,0xB801,0xFE00,0x7F00,0x0067,0xBC00,0xFF00,
  61.         0xBE00,0x0079,0x9E00,0x3F00,0xD800,0x003C,0x6F00,0x1F00,
  62.         0xE000,0x003D,0xF700,0x0F00,0xE006,0x001E,0xF700,0x0700,
  63.         0xC018,0x001E,0xFA00,0x0700,0x8020,0x000F,0x7000,0x0300,
  64.         0x0040,0x600F,0x0000,0x0300,0x0081,0x8000,0x0000,0x0200,
  65.         0xF902,0x0000,0x0000,0x0100,0xFF04,0x0000,0x0000,0x0700,
  66.         0xFF88,0x0C00,0x0000,0x0F00,0xBFD0,0x3000,0x0000,0x1F00,
  67.         0xFFE0,0xC000,0x0000,0x6F00,0xFFE1,0x0000,0x0001,0xF700,
  68.         0xFFE2,0x0000,0x0007,0xF700,0x1FE4,0x0000,0x0000,0x0000,
  69.         0x0FE8,0x0000,0x0000,0x0000,0x0FF0,0x0000,0x0000,0x0000,
  70.         0x0FE0,0x0000,0x0000,0x0000,0x1FE0,0x0000,0x0000,0x0000,
  71.         0x3FE0,0x0000,0x3030,0x0000,0x7FA0,0x0000,0xC0C0,0xC000,
  72.         0xFFA0,0x0001,0x0103,0x0000,0xFF20,0x0002,0x0204,0x0300,
  73.         0xFE20,0x1FFC,0x0408,0x0F00,0xFC20,0x63FF,0x8810,0x1F00,
  74.         0xF821,0x87FF,0xF020,0x3F00,0xF066,0x0FFF,0xF840,0x7F00,
  75.         0xE09C,0x1FFF,0xFC40,0xFF00,0xE104,0x1FFF,0xFE81,0xFF00,
  76.         0xE108,0x3FF9,0xFF81,0xFF00,0xF208,0x3FFE,0x7FC3,0xFF00,
  77.         0xFA10,0x7FFF,0x9FE3,0xFF00,0xFF10,0x7F9F,0xEFF3,0xFF00
  78.     };
  79.  
  80.     struct RastPort RastPort;
  81.  
  82.     LayoutHandle *Handle = (LayoutHandle *)Hook->h_Data;
  83.  
  84.     LONG    PatternWidth,
  85.             PatternHeight;
  86.  
  87.     LONG    FromMinX,FromMinY,FromMaxX,FromMaxY,
  88.             SaveMinX,SaveMaxX,SaveToMinX,
  89.             ToMinX,ToMinY;
  90.     LONG    Width,Height;
  91.     LONG    Offset;
  92.     LONG    Modulo;
  93.  
  94.     InitRastPort(&RastPort);
  95.     RastPort.BitMap = RPort->BitMap;
  96.     SetABPenDrMd(&RastPort,Handle->DrawInfo->dri_Pens[FILLPEN],Handle->DrawInfo->dri_Pens[BACKGROUNDPEN],JAM2);
  97.  
  98.     Modulo = ((56 + 15) >> 4) * 2;
  99.  
  100.         // Pick up the initial data
  101.  
  102.     PatternWidth    = 56;
  103.     PatternHeight    = 54;
  104.  
  105.     ToMinX            = Bounds->Bounds.MinX;
  106.     ToMinY            = Bounds->Bounds.MinY;
  107.  
  108.     FromMinX        = Bounds->Bounds.MinX;
  109.     FromMinY        = Bounds->Bounds.MinY;
  110.  
  111.     FromMaxX        = Bounds->Bounds.MaxX;
  112.     FromMaxY        = Bounds->Bounds.MaxY;
  113.  
  114.         // NOTEZ-BIEN: the following layer offset adjustments are for
  115.         //             window layer backfill only, for screen layer
  116.         //             backfills the Layer pointer would be invalid.
  117.  
  118.         // Adjust for window left edge
  119.  
  120.     if(Offset = Bounds->Layer->bounds.MinX % PatternWidth)
  121.     {
  122.         FromMinX += Offset;
  123.         FromMaxX += Offset;
  124.     }
  125.  
  126.         // Adjust for window top edge
  127.  
  128.     if(Offset = Bounds->Layer->bounds.MinY % PatternHeight)
  129.     {
  130.         FromMinY += Offset;
  131.         FromMaxY += Offset;
  132.     }
  133.  
  134.         // Save these for later
  135.  
  136.     SaveMinX    = FromMinX;
  137.     SaveMaxX    = FromMaxX;
  138.     SaveToMinX    = ToMinX;
  139.  
  140.     do
  141.     {
  142.         do
  143.         {
  144.                 // Unwrap the left edge
  145.  
  146.             if(PatternWidth <= FromMinX)
  147.             {
  148.                 LONG OldMinX = FromMinX;
  149.  
  150.                 FromMinX %= PatternWidth;
  151.                 FromMaxX -= (OldMinX - FromMinX);
  152.             }
  153.  
  154.                 // Unwrap the top edge
  155.  
  156.             if(PatternHeight <= FromMinY)
  157.             {
  158.                 LONG OldMinY = FromMinY;
  159.  
  160.                 FromMinY %= PatternHeight;
  161.                 FromMaxY -= (OldMinY - FromMinY);
  162.             }
  163.  
  164.                 // Stay within horizontal bounds
  165.  
  166.             if((Width = FromMaxX) >= PatternWidth)
  167.                 Width = PatternWidth - 1;
  168.  
  169.             Width = Width - FromMinX + 1;
  170.  
  171.                 // Stay within vertical bounds
  172.  
  173.             if((Height = FromMaxY) >= PatternHeight)
  174.                 Height = PatternHeight - 1;
  175.  
  176.             Height = Height - FromMinY + 1;
  177.  
  178.                 // Blast in the image
  179.  
  180.             BltTemplate(&((PLANEPTR)EscherData)[FromMinY * Modulo + ((FromMinX & ~0xF) / 8)],FromMinX & 0xF,Modulo,&RastPort,ToMinX,ToMinY,Width,Height);
  181.  
  182.                 // Move up to next column
  183.  
  184.             FromMinX    += Width;
  185.             ToMinX         += Width;
  186.         }
  187.         while(FromMaxX >= FromMinX);
  188.  
  189.             // Return to first column
  190.  
  191.         FromMinX    = SaveMinX;
  192.         FromMaxX    = SaveMaxX;
  193.         ToMinX        = SaveToMinX;
  194.  
  195.             // Move up to next row
  196.  
  197.         Height = PatternHeight - 1 - FromMinY + 1;
  198.  
  199.         FromMinY    += Height;
  200.         ToMinY        += Height;
  201.     }
  202.     while(FromMaxY >= PatternHeight);
  203. }
  204. */
  205.